/*-------------------------------------------------------------------------------------------------------------------------
	AFK Notifier
-------------------------------------------------------------------------------------------------------------------------*/

local PLUGIN = {}
PLUGIN.Title = "AFK Notify"
PLUGIN.Description = "Shows people who seem to be AFK that they are."
PLUGIN.Author = "Overv"

function PLUGIN:PlayerSpawn( ply )
	ply.EV_AFKTime = os.time()
end

function PLUGIN:KeyPress( ply )
	ply.EV_AFKTime = os.time()
end

function PLUGIN:PlayerSay( ply )
	ply.EV_AFKTime = os.time()
end

PLUGIN.Messages = { "watching porn",
	"wanking",
	"AFK",
	"thinking of funny lines for this",
	"coming out of the closet",
	"getting some action",
	"giggity giggity gooing",
	"jacking off",
	"becoming a communist",
	"being stalked",
	"being molested",
	"a sexual Panda",
	"dead",
	"unable to move due to requested inactivity",
	"grabbin pills",
	"smoking weed in the basement",
	"wrapping presents",
	"riding santa's sleigh",
	"getting in the back of Matt's van",
	"riding an ostrich",
	"feeding a BBD",
	"a non-moving statue",
	"herding cheese",
	"feeding a chicken",
	"reading the Bible backwards",
	"talking to the cats" }

function PLUGIN:Think()
	for _, pl in ipairs( player.GetAll() ) do
		if ( pl:GetAngles() != pl.EV_AFKAngles ) then
			pl.EV_AFKTime = os.time()
			pl.EV_AFKAngles = pl:GetAngles()
		end
		
		if ( pl.EV_AFKTime and os.time() - pl.EV_AFKTime == 60.00 ) then
		local r = math.random(1,table.Count(PLUGIN.Messages))
			if pl:GetProperty("AFK1") == true then
			evolve:Notify( evolve.colors.blue, pl:Nick(), evolve.colors.white, " appears to be ", evolve.colors.red, "AFK", evolve.colors.white, "." )
			pl.EV_AFKTime = 0
			else
			evolve:Notify( evolve.colors.blue, pl:Nick(), evolve.colors.white, " appears to be ", evolve.colors.red, PLUGIN.Messages[r], evolve.colors.white, "." )
			pl.EV_AFKTime = 0
			end
		end
	end
	end

evolve:RegisterPlugin( PLUGIN )